//
//  BaseObject.m
//  SingleMessageToForwording
//
//  Created by LY on 2017/11/8.
//  Copyright © 2017年 DesignPatterns. All rights reserved.
//

#import "BaseObject.h"
#import <objc/runtime.h>
@implementation BaseObject
+ (BOOL)resolveInstanceMethod:(SEL)sel{
    if (![super resolveInstanceMethod:sel]) {
        NSString * methodNameString = @"crashAction";
        SEL addmethod = NSSelectorFromString(methodNameString);
        IMP addIMP = class_getMethodImplementation(self, addmethod);
        class_addMethod(self, addmethod,addIMP,"v");
        return true;
    }else{
        return  true;
    }
}
+ (BOOL)resolveClassMethod:(SEL)sel{
    return true;
}
- (id)forwardingTargetForSelector:(SEL)aSelector{
    return nil;
}
- (void)forwardInvocation:(NSInvocation *)anInvocation{
    
}
+ (void)crashAction{
    printf("成功拦截");
}
@end
